{include file="public/header"}
<body>
<fieldset class="layui-elem-field">
    <legend>用户列表</legend>
    <div class="layui-field-box">
        
        <table class="layui-table" lay-even>
            <thead>
            <tr>
                <th>序号</th>
                <th>代理商编号</th>
                <th>商户号</th>
                <th>商户状态</th>
                <th>注册时间</th>
                <th>电话</th>
                <th>商户名称</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody  id="searchContent">
            {volist name="list" id="vo"}
            <tr>
                <td><?php echo ($key+1)+(($page-1)*10)?></td>
                <td>{$vo['chnlId']}</td>
                <td>{$vo['merId']}</td>
                <td>{$vo['merStat']}</td>
                <td>{$vo['regDate'].$vo['regTime']}</td>
                <td>{$vo['merMp']}</td>
                <td>{$vo['merName']}</td>
                <td>
                    <span  class="layui-btn layui-btn-normal">查询</span>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
    </div>
</fieldset>
<div id="demo1"></div>


{include file="public/footer"}
<script>
    layui.use(['layer'], function() {});
    layui.use(['laypage', 'layer'], function(){
        var laypage = layui.laypage,layer = layui.layer;
        laypage({
            cont: 'demo1'
            ,pages: {$totalPage} //总页数
            ,groups: 5 //连续显示分页数
            ,curr:{$page}
            ,jump: function(obj, first){
                //得到了当前页，用于向服务端请求对应数据
                var curr = obj.curr;
                if(!first){
                    window.location.href='/admin/agent/users/page/'+curr
                }

            }
        });
    });
    function edit(id) {
        layer.open({
            type: 2,
            area: ['90%', '90%'],
            maxmin: true,
            content: '/admin/agent/edit/id/'+id
        });
    }
    function showorder(id)
    {
        layer.open({
            type: 2,
            area: ['90%', '90%'],
            maxmin: true,
            content: '/admin/order/index/merId/'+id
        });

    }
    function showFee(id) {
        layer.open({
            type: 2,
            area: ['90%', '90%'],
            maxmin: true,
            content: '/admin/agent/showFee/id/'+id
        });
    }
    function search(id) {
        layer.confirm('你确定要删除该代理商么?', {
            btn: ['确定','取消'] //按钮
        }, function(){
            var params  = {
                url: '{:url("del")}',
                data: {id:id},
                type: 'post',
                sCallback:function(res){
                    layer.msg(res.msg,{time:1800},function(){
                        location.reload();
                    });
                }
            };
            common.request(params);
        });
    }

    $('#seach').on('click', function () {
        var params  = {
            url : "{:url('agent/agent/index')}",
            data: $("#seachForm").serialize(),
            type: 'post',
            sCallback:function(res){
                var travelHtml = [];
                for (var i=0; i < res.data.length; i++) {
                    var id = res.data[i]["id"];
                    travelHtml +='<tr> ' + '<td>'+(i+1)+'</td> ' +
                            '<td>'+res.data[i]["name"]+'</td> ' +
                            '<td>'+res.data[i]["mobile"]+'</td> ' +
                            '<td>'+res.data[i]["agent_num"]+'</td> ' +
                            '<td>'+res.data[i]["uper_name"]+'</td> ' +
                            '<td>'+res.data[i]["account"]+'</td> ' +
                            '<td>' +
                            '{if condition="'+ res.data[i][status] + ' === 0"} ' +
                            '<span style="border-radius: 2px;background-color: #FF5722;padding:5px 10px;color: #ffffff">禁用</span>' +
                            '{else /} ' +
                            '<span style="border-radius: 2px;background-color: #5FB878;padding:5px 10px;color: #ffffff">正常</span>' +
                            '{/if} ' +
                            '</td> ' +
                            '<td> ' +
                            '<span onclick="edit('+ id +')"  class="layui-btn edit1 layui-btn-normal">编辑</span>' +
                            '<span onclick="search('+ id +')" class="layui-btn layui-btn-danger confirm">删除</span> ' +
                            '</td> ' + '</tr>';
                };
                $('#searchContent').html(travelHtml);
            }
        };
        common.request(params);
    });
    $('#allAgent').click(function() {
        window.location.href = "{:url('index')}";
    });
</script>
</body>
</html>